from socket import *
import struct
myHost = ''                           
myPort = 50007                       

sockobj = socket(AF_INET, SOCK_STREAM)     
sockobj.bind((myHost, myPort))            
sockobj.listen(5)                        
video = open('../../DESENVOLVIMENTO/provider/lost.avi', 'r')
Saida=False
while 1:                                   
    connection, address = sockobj.accept() 
    print 'Server connected by', address   
    data = connection.recv(1024)
    print data
    if data.strip() == 'PLAY':
	count = 0
	while 1:
	    for stream in video.readlines():
	        #data = struct.pack('>i4sh',count,stream)
		count=count+1
	        connection.send(stream)
	   # Saida = True

    else:
	pass
